package com.yb.xczx.cloud.auth.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/5/14 12:19
 * FileName: IndexController
 * Description:
 */

@Controller
@Slf4j
public class IndexController {

    @RequestMapping("")
    public String index(){
        log.error("访问index");
        return "index";
    }

    @RequestMapping("authorized")
    public String authorized(Model model,@RequestParam(required = false) String code,@RequestBody(required = false)  String requestBody){
        model.addAttribute("code",code);
        model.addAttribute("body",requestBody);
        return "toAuth";
    }

    @RequestMapping("token")
    public String token(Model model,@RequestBody String token){
        model.addAttribute("token",token);
        return "token";
    }

    @RequestMapping("hello.html")
    public String helloHtml(){

        return "hello";
    }

    @RequestMapping("/access/token")
    public String accessToken(@RequestBody String body,Model model){
        model.addAttribute("body",body);
        return "accessToken";
    }
}
